Hello and welcome to this video on our of functions our functions sometimes called fat Harrow functions
have an abbreviated syntax for working with the function they are represented by BE equal sign and big
great symbol.
Don't confuse this with comparison operators because it does something quite different.
So I'm going to illustrate with an example.
So you can see how our all functions work side by side.
My text editor here I have created a variable here called student lists.
We've said that two equals two functions.
We pass in it's too dense as I remember and there were console logging in the students that were passed.
Here again I'm calling the function an impasse in it an array here we two values John and Jane.
So this is a typical function expression.
I'm going to re model this or refactor this code using an arrow function so you can see how the arrow
function actually works.
So that piece of code here if you run it inside the console of your web browser it will display something
like this.
So make sure you have the console selected and click on that to see the two values of the harrie's here
which is this to here John and Jane.
So now let's refactored this court with an hour of fanshen.
Right let's.
We -- up this course.
First thing I want to do is remove this function key word and unleash that again let's remove that to
trying to shorten because I remove this curly braces.
That's the only one I get rid of that as well.
I just bring that could be nearer.
I'm also going to bring this console log here.
I'm going to make print it on the same lie just to shorten the code and we need to add our function
here so and do that and then the greater than sign so that our function in there so you can see just
by using a function we have reduced the amount of code to be written we've actually shortened the code.
So I expect to get the same output.
I'm just going to see my code and our lunch my browser again and to see if I get the same I should get
the same output.
You can see here I'm getting the same outputs as you are using in browser Babbo transformer.
Some got John and J.
So that's basically how you use our function.
The main purpose of an IRA function is to shorten the expression use.
Okay so by using that got real optical embraces and should tint my code.
I can solve for shorting this code because I'm only passing one argument which is the students I can
remove the parenthesised that shoots to work.
However if you are passing in more than one argument you do need to include them in parenthesis.
So I'm going to say that wrong the code again.
He should I should get the same output.
I do a refresh.
It can see the output is to the same.
Alright so that's basically how our functions work.
Functions are a great way to make your javascript code more readable and more compact.